package com.jiangruan.javaApiProject.service;

import bean.HotVideo;
import bean.HotVideoCommon;
import com.alibaba.fastjson.JSONObject;
import com.jiangruan.javaApiProject.Constants;
import com.jiangruan.javaApiProject.net.HttpUtils;

import java.util.List;

/**
 * @Author 默
 * @Date 15:59 2021/12/5
 * @desc
 * @Description
 */
public class HotVideoService {
    /**
     * 该方法用于获取热门数据，并将热门数据进行放回
     * @return
     */

    public static List<HotVideo> getHotVideo(){
        String url = Constants.TRIP_URL
                + "?key=" + Constants.TRIP_KEY
                + "&type=hot_video"
                + "&size=0";
        String result = HttpUtils.get(url);

        //对热门视频榜进行json解析
        HotVideoCommon videoCommon = JSONObject.parseObject(result, HotVideoCommon.class);


        return videoCommon.result;
    }
}
